<?php
declare(strict_types=1);

namespace LowCode\Naive;

use LowCode\Naive;
use LowCode\Traits\Props\HasColor;
use LowCode\Traits\Props\HasMax;
use LowCode\Traits\Props\HasShow;
use LowCode\Traits\Props\HasType;
use LowCode\Traits\Props\HasValue;

/**
 * 组件 - 固钉 Badge
 *  @method static static make(mixed $children = null) Badge组件
 */
class Badge extends Naive
{
    use HasColor, HasShow, HasType, HasValue, HasMax;

    public function __construct(mixed $children = null)
    {
        parent::__construct();
        $this->children($children);
    }

    /**
     * 标记显示类型
     * @param string $type 'default' | 'info' | 'success' | 'warning' | 'error'
     * @return $this
     */
    public function type(string $type = 'default' | 'info' | 'success' | 'warning' | 'error'): static
    {
        return $this->prop('type',$type);
    }

    /**
     * 默认标签类型
     * @return $this
     */
    public function default(): static
    {
        return $this->type('default');
    }

    /**
     * 标记显示进度
     * @param bool $bool
     * @return $this
     */
    public function processing(bool $bool = true): static
    {
        return $this->prop('processing', $bool);
    }

    /**
     * 标记为 0 时是否显示
     * @param bool $bool
     * @return $this
     */
    public function showZero(bool $bool = true): static
    {
        return $this->prop('showZero', $bool);
    }

    /**
     * 标记是否显示为点
     * @param bool $bool
     * @return $this
     */
    public function dot(bool $bool = true): static
    {
        return $this->prop('dot', $bool);
    }

    /**
     * 距默认位置左侧、上方的偏移量
     * @param array|string $value [string | number, string | number]
     * @return $this
     */
    public function offset(array|string $value = [0,0]): static
    {
        return $this->prop('offset', $value);
    }
}
